// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'

import './common/styleus/style.css';

import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'

Vue.use(VueQuillEditor, /* { default global options } */)

import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import {
  Pagination,
  Dialog,
  Autocomplete,
  Dropdown,
  DropdownMenu,
  DropdownItem,
  Menu,
  Submenu,
  MenuItem,
  MenuItemGroup,
  Input,
  InputNumber,
  Radio,
  RadioGroup,
  RadioButton,
  Checkbox,
  CheckboxButton,
  CheckboxGroup,
  Switch,
  Select,
  Option,
  OptionGroup,
  Button,
  ButtonGroup,
  Table,
  TableColumn,
  DatePicker,
  TimeSelect,
  TimePicker,
  Popover,
  Tooltip,
  Breadcrumb,
  BreadcrumbItem,
  Form,
  FormItem,
  Tabs,
  TabPane,
  Tag,
  Tree,
  Alert,
  Slider,
  Icon,
  Row,
  Col,
  Upload,
  Progress,
  Spinner,
  Badge,
  Card,
  Rate,
  Steps,
  Step,
  Carousel,
  CarouselItem,
  Collapse,
  CollapseItem,
  Cascader,
  ColorPicker,
  Transfer,
  Container,
  Header,
  Aside,
  Main,
  Footer,
  Timeline,
  TimelineItem,
  Link,
  Divider,
  Image,
  Calendar,
  Backtop,
  PageHeader,
  CascaderPanel,
  Loading,
  MessageBox,
  Message,
  Notification
} from 'element-ui';


import App from './App'
import VueRouter from 'vue-router'

import VueResource from 'vue-resource';
import axios from 'axios';

//使用elementUi
Vue.use(ElementUI);
//以下为实例所有elementUi组件
Vue.use(Pagination);
Vue.use(Dialog);
Vue.use(Autocomplete);
Vue.use(Dropdown);
Vue.use(DropdownMenu);
Vue.use(DropdownItem);
Vue.use(Menu);
Vue.use(Submenu);
Vue.use(MenuItem);
Vue.use(MenuItemGroup);
Vue.use(Input);
Vue.use(InputNumber);
Vue.use(Radio);
Vue.use(RadioGroup);
Vue.use(RadioButton);
Vue.use(Checkbox);
Vue.use(CheckboxButton);
Vue.use(CheckboxGroup);
Vue.use(Switch);
Vue.use(Select);
Vue.use(Option);
Vue.use(OptionGroup);
Vue.use(Button);
Vue.use(ButtonGroup);
Vue.use(Table);
Vue.use(TableColumn);
Vue.use(DatePicker);
Vue.use(TimeSelect);
Vue.use(TimePicker);
Vue.use(Popover);
Vue.use(Tooltip);
Vue.use(Breadcrumb);
Vue.use(BreadcrumbItem);
Vue.use(Form);
Vue.use(FormItem);
Vue.use(Tabs);
Vue.use(TabPane);
Vue.use(Tag);
Vue.use(Tree);
Vue.use(Alert);
Vue.use(Slider);
Vue.use(Icon);
Vue.use(Row);
Vue.use(Col);
Vue.use(Upload);
Vue.use(Progress);
Vue.use(Spinner);
Vue.use(Badge);
Vue.use(Card);
Vue.use(Rate);
Vue.use(Steps);
Vue.use(Step);
Vue.use(Carousel);
Vue.use(CarouselItem);
Vue.use(Collapse);
Vue.use(CollapseItem);
Vue.use(Cascader);
Vue.use(ColorPicker);
Vue.use(Transfer);
Vue.use(Container);
Vue.use(Header);
Vue.use(Aside);
Vue.use(Main);
Vue.use(Footer);
Vue.use(Timeline);
Vue.use(TimelineItem);
Vue.use(Link);
Vue.use(Divider);
Vue.use(Image);
Vue.use(Calendar);
Vue.use(Backtop);
Vue.use(PageHeader);
Vue.use(CascaderPanel);

Vue.use(Loading.directive);

Vue.prototype.$loading = Loading.service;
Vue.prototype.$msgbox = MessageBox;
Vue.prototype.$alert = MessageBox.alert;
Vue.prototype.$confirm = MessageBox.confirm;
Vue.prototype.$prompt = MessageBox.prompt;
Vue.prototype.$notify = Notification;
Vue.prototype.$message = Message;

Vue.use(VueResource);
Vue.prototype.$ajax=axios;

Vue.use(VueRouter);
//创建组件
import Hello from './components/HelloWorld.vue'
import LoginTest from './components/LoginTest.vue';
import SearchBox from './components/SearchBox.vue';
import Partition from './components/Partition.vue';
import SelfCenter from './components/SelfCenter.vue';
import FileUpload from './components/Upload.vue';
import ColumnPartition from './components/ColumnPartition.vue'
import ColumnContribution from './components/ColumnContribution.vue';
import ReadColumn from './components/ReadColumn.vue'
import VideoView from './components/VideoView.vue';
import SearchResult from './components/SearchResult.vue';
import Recommend from './components/Recommend.vue'
import cCarousel from './components/Carousel.vue'



//后台管理界面组件
import AdminLogin from './components/AdminView/AdminLogin.vue';
import ManagementPage from './components/AdminView/ManagementPage.vue';

//实例化VueRouter
const router=new VueRouter({
  //去除地址前的＃号
  mode:'history',
  //默认根地址
  base:'jy',
   routes:[
     {
       path:'/hello',
       components:{
         'hello':Hello
       }
     },
    //主站的路由跳转
    {
      path:'/main',
      components:{
        default:SearchBox,
        'recommend':Recommend,
        'columnPartition':ColumnPartition,
        'ccarousel':cCarousel,
        'partitionJava':Partition,
        'partitionC':Partition,
        'partitionPython':Partition,
        'partitionSpring':Partition,
        'partitionAndroid':Partition
      }
    },
    //登录&注册的路由跳转
    {
      path:'/loginRegister',
      components:{
        default:LoginTest,
      }
    },
    //登陆后用户个人中心
    {
      path:'/selfCenter',
      components:{
        default:SearchBox,
        'selfCenter':SelfCenter
      }
    },
    //上传资源页面的路由
    {
      path:'/FileUpload',
      components:{
        // default:SearchBox,
        'FileUpload':FileUpload
      }
    },
    //专栏推荐组件的路由
    {
      path:'/columnPartition',
      components:{
        // default:SearchBox,
        'columnPartition':ColumnPartition
      }
    },
    //上传资源页面的路由
    {
      path:'/columnContribution',
      components:{
        // default:SearchBox,
        'columnContribution':ColumnContribution
      }
    },
    //上传资源页面的路由
    {
      path:'readColumn/:id',
      name:'readColumn',
      components:{
        // default:SearchBox,
        'readColumn':ReadColumn
      }
    },
    // 重定向----原因：当地址路由到/readColumn/:id时，再次点击main或者loginRegister的路由时
      //地址将会变为/readColumn/main或者/readColumn/loginRegister
      //很明显上述地址未设定路由，即地址改变页面无反应
    //暂时的解决方法是重定向----即以下方法
    {
      path:'/readColumn/main',redirect:'/main'
    },
    {
      path:'/readColumn/loginRegister',redirect:'/loginRegister'
    },
    //动态重定向
    // {
    //   path:'/readColumn/:id',redirect: to =>{
    //     const {hash,params,query} = to
    //     if(query.to ===  '/main'){
    //       return {path:'/main',query:null}
    //     }
    //     if(query.to === '/loginRegister'){
    //       return {path:'/loginRegister',query:null}
    //     }
    //   }
    // },
    {
      path:'/videoview',
      components:{
        default:SearchBox,
        'videoview':VideoView
      }
    },
    //后台管理部分--login页面
    {
      path:'/adminViewLogin',
      components:{
        // default:SearchBox,
        default:AdminLogin,
        // 'adminLogin':AdminLogin
      }
    },
    //后台管理部分--管理员管理页面
    {
      path:'/managementPage',
      components:{
        // default:SearchBox,
        default:ManagementPage,
      }
    },
    //搜索后的结果将显示在这个页面
    {
      path:'/searchResult',
      components:{
        default:SearchBox,
        'searchResult':SearchResult
      }
    },
  ],

})
//挂载路由


// axios 配置

axios.defaults.timeout = 5000;

//axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8';

axios.defaults.headers.post['Content-Type'] = 'application/json;charset=UTF-8';

// axios.defaults.headers.post['Content-Type'] = 'json';

// axios.defaults.baseURL = 'http://localhost:8080/项目名/';

axios.defaults.baseURL = 'http://localhost:8080/';


Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
